package com.shanliao.controller;


import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.shanliao.model.User;
import com.shanliao.request.BaseRequest;
import com.shanliao.request.UserRegisterRequest;
import com.shanliao.respone.BaseResponse;
import com.shanliao.service.IUserService;
import com.shanliao.version.annatation.ApiVersion;
import com.shanliao.version.annatation.ApiVersionEnum;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jason
 * @since 2019-10-05
 */
@RestController
@RequestMapping("/{version}/demo")
public class DemoController extends BaseController{
	
	@Autowired
	private IUserService userService;
	@GetMapping("hello")
    @ApiVersion(ApiVersionEnum.v1_0_0)
    public ResponseEntity<String> hello(HttpServletRequest request){
        System.out.println("haha1..........");
        return response("hello");
    }
     
	@GetMapping("hello")
    @ApiVersion(ApiVersionEnum.v2_0_0)
    public String hello2(HttpServletRequest request){
        System.out.println("haha2.........");
         
        return "hello";
    }
     
	@GetMapping("hello")
    @ApiVersion(ApiVersionEnum.v5_0_0)
    public String hello5(HttpServletRequest request){
        System.out.println("haha5.........");
         
        return "hello";
    }
	@PostMapping("hello")
	@ApiVersion(ApiVersionEnum.v6_0_0)
	public ResponseEntity<String> hello6(@RequestBody @Valid BaseRequest<UserRegisterRequest> baseRequest){
		System.out.println("haha6.........");
		return responseData(BaseResponse.success(new User(), "返回用户信息"));
	}
}
